#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int T;
struct car{
    int d,v,a;
}a[N];
int c[N];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    scanf("%d",&T);
    while(T--){
        int n,m,L,V;
        scanf("%d %d %d %d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++) scanf("%d %d %d",&a[i].d,&a[i].v,&a[i].a);
        for(int i=1;i<=m;i++) scanf("%d",&c[i]);
        printf("%d %d\n",n,m-3);
    }
    return 0;
}
